import React, { Component } from 'react'
import { Swiper } from 'react-vant';
import axios from "axios"
 class Swiper1 extends Component {
  state = {
      arr:[]
  }
  componentDidMount(){
        axios.get("/list").then(res=>{
            console.log(res.data)
            this.setState({
                arr:res.data.list
            })
        })
  }
  render() {
     let {arr} = this.state
    return (
      <div>
          {
              arr&&arr.length?<Swiper className="my-swipe" autoplay={3000}>
          
              {
                 arr.map((item,index)=>{
                     return   <Swiper.Item key={index}>
                          <img src={item}></img>
                     </Swiper.Item>
                 }) 
              }
           </Swiper>:"图片没有返回"
          }
           
      </div>
    )
  }
}

export default Swiper1